/**
 * Created by leon on 2017/4/27.
 */
(function () {
    'use strict';

    angular.module('App.pages.member')
        .controller('MemberOfFamilyCtrl', MemberOfFamilyCtrl);

    function MemberOfFamilyCtrl($scope,MemberModel,$location,$state,LoginAccountAuth) {

        // $scope.$on('$ionicView.beforeEnter', function (event, viewData) {
        //     viewData.enableBack = true;
        // });



        var vm = this;
        var objParams={};
        $scope.studentInfo = {};
        $scope.relType = {};


        LoginAccountAuth.getAccount().then(function(data){
            vm.loginAccount = data;
            objParams.id= vm.loginAccount.memberId;
            MemberModel.getStudentInfoByParentId(objParams).$promise.then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    vm.studentInfo=response.studentInfo;
                    vm.relType=response.relType;
                    console.info(response.studentInfo);
                }
            });

            MemberModel.getMemberInfo(objParams).$promise.then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    vm.memberInfo = response.memberInfo;
                }
            });

            vm.familyInfo = [];
            var obj={};
            obj.memberId= '8F0E9C2C8C2B96498EE8AF60E205838E';
            MemberModel.getfamilyInfo(obj).$promise.then(function(response){
                // if(response.stat == 'err'){
                //     AppUtils.showAlert(response.msg);
                // }else{
                vm.familyInfo=response.familyInfo;
                // console.info(vm.familyInfo);
                // }
            });
        });



        // $scope.stduentInfo={};
        // objParams.stduentId=studentId;
        // MemberModel.findStudentByParentId(objParams).$promise.then(function (response) {
        //     if(response.stat == 'err'){
        //         AppUtils.showAlert(response.msg);
        //     }else{
        //         vm.studentInfo = response.studentInfo;
        //         console.info(response.studentInfo);
        //     }
        // });
        // $scope.familyInfo={};


        $scope.jumpToUrl=function () {
            // $location.path("/member/changeRel/A83FA905F6044E9CA30C52FDCD351794");
            $state.go("memberMenu.changeRel",{studentId:'A83FA905F6044E9CA30C52FDCD351794'});
            // $location.path("/member/changeRel/"+id);
        }

    }
})();